package top.kaoshanji.p1ch01a;

import org.junit.Test;
import org.mockito.Mockito;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/4/21 22:34
 */
public class BraveKnightTest {

    /**
     * 代码清单test-p1ch01a-7页b：为了测试BraveKnight，需要注入一个 mock Quest
     */
    @Test
    public void knightShouldEmbarkOnQuest() {

        // 创建 mock Quest...
        Quest mockQuest = Mockito.mock(Quest.class);

        // 注入 mock Quest
        BraveKnight knight = new BraveKnight(mockQuest);
        knight.embarkOnQuest();

        Mockito.verify(mockQuest, Mockito.times(1)).embark();
    }

}
